function currency(strings, ...values) {
    return strings.reduce((result, string, i) => {
        let value = values[i - 1];
        if (typeof value === 'number') {
            value = `$${value.toFixed(2)}`;
        }
        return result + value + string;
    })
}

const price = 19.5005;
// 带标签的模板允许使用函数解析
const formatted = currency`The total prices is ${price} .`;

console.log(formatted)